

$(document).ready(function () {	
	
	$(document).ready( function(){
		pag= $('#count').val();
	})
	$(".load").hide();
	$("#pages").paginate({
		count: +pag,
		start: 1,
		display: 7,
		border: true,
		border_color: '#fff',
		text_color: '#fff',
		background_color: 'black',	
		border_hover_color: '#ccc',
		text_hover_color: '#000',
		background_hover_color: '#fff', 
		images: false,
		mouse: 'press',
		onChange: function(page){

			$('._current','#pagination').removeClass('_current').hide();
			$('#p'+page).addClass('_current').show();

			$(function() {
				var i = getRandomArbitary(150, 400);
				$(".load").fadeIn();
				$.ajax({
					url: '/ajax/get_image',
					type: "POST",
					dataType:"json",
					cache: false,
					async: true,
					data: "page=" + page,
					success:function(result){
						str = '<div id="p" class="_current" ><ul id="gallery">';
						$.each(result, function(key,elem) {
							str += '<li><a class="full"  id = ' + elem.id + ' ><img src='+ elem.images + '></a></li>';
						});
						str +='</ul></div>' 
						$(".load").fadeOut(i);	
						$(".wrap").html(str).hide().fadeIn(i);
						full();
					}
				});
			});
		}
	});
	
});

function getRandomArbitary(min, max)
{
	return Math.floor(Math.random() * (max - min + 1)) + min;
}


